package cn.iocoder.yudao.module.ym.dal.mysql.connection;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
import cn.iocoder.yudao.module.ym.dal.dataobject.connection.ConnectionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ym.controller.admin.connection.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 区域电站人员关联 Mapper
 *
 * @author 韩艳阳
 */
@Mapper
public interface ConnectionMapper extends BaseMapperX<ConnectionDO> {

    default PageResult<ConnectionDO> selectPage(ConnectionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConnectionDO>()
                .betweenIfPresent(ConnectionDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConnectionDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ConnectionDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ConnectionDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(ConnectionDO::getPeopleId, reqVO.getPeopleId())
                .eqIfPresent(ConnectionDO::getThingId, reqVO.getThingId())
                .eqIfPresent(ConnectionDO::getType, reqVO.getType())
                .orderByDesc(ConnectionDO::getId));
    }


    default List<ConnectionDO> selectList(ConnectionPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ConnectionDO>()
                .betweenIfPresent(ConnectionDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConnectionDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ConnectionDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ConnectionDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(ConnectionDO::getPeopleId, reqVO.getPeopleId())
                .eqIfPresent(ConnectionDO::getThingId, reqVO.getThingId())
                .eqIfPresent(ConnectionDO::getType, reqVO.getType())
                .orderByDesc(ConnectionDO::getId));
    }

    default List<ConnectionDO> selectListByAreaIds(Collection<Long> areaIds) {
        return selectList(new LambdaQueryWrapperX<ConnectionDO>()
                .eq(ConnectionDO::getType,1)
                .in(ConnectionDO::getThingId,areaIds));
    }

    List<ConnectionDO> selectBySiteIds(@Param("siteIds") List<Long> siteIds, @Param("size") Integer size);
}
